package com.lishe.lishe.lishe.module.shopingcart.bean;

import com.google.gson.annotations.SerializedName;

import java.io.Serializable;
import java.util.ArrayList;
import java.util.List;

/**
 * Created by shino on 2017/12/28.
 * 商店对象
 */

public class StoreObject implements Serializable {
    //商店id
    @SerializedName("shop_id")
    private String shop_id;

    //商店名称
    @SerializedName("shop_name")
    private String shop_name;

    //商店下的所有商品
    @SerializedName("goodsInfo")
    private List<GoodObject> goodObjects = new ArrayList<>();

    //全选商铺下的商品
    private boolean isCheck = false;

    //支付金额
    private double payment;

    public String getShop_id() {
        return shop_id;
    }

    public void setShop_id(String shop_id) {
        this.shop_id = shop_id;
    }

    public String getShop_name() {
        return shop_name;
    }

    public void setShop_name(String shop_name) {
        this.shop_name = shop_name;
    }

    public List<GoodObject> getGoodObjects() {
        return goodObjects;
    }

    public void setGoodObjects(List<GoodObject> goodObjects) {
        this.goodObjects = goodObjects;
    }

    public boolean isCheck() {
        return isCheck;
    }

    public void setCheck(boolean check) {
        isCheck = check;
    }

    public double getPayment() {
        if (payment == 0) {
            for (GoodObject goodObject : goodObjects) {
                if (isCheck) {
                    payment = payment + goodObject.getPrice() * goodObject.getQuantity();
                }
            }
        }
        return payment;
    }

    public void setPayment(double payment) {
        this.payment = payment;
    }
}
